package com.alipay.app.groupmeal.standard.offline;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.alipay.app.groupmeal.standard.offline.bean.DaoMaster;
import com.alipay.app.groupmeal.standard.offline.bean.OrderBeanDao;

import org.greenrobot.greendao.database.Database;

/**
 * @ProjectName: 团餐
 * @ClassName: ExampleOpenHelper
 * @Description: java类作用描述
 * @Author: bd-001935
 * @CreateDate: 7/14/22 3:31 PM
 * @UpdateUser: bd-001935
 * @UpdateDate: 7/14/22 3:31 PM
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class MySQLiteOpenHelper extends DaoMaster.OpenHelper {

    public MySQLiteOpenHelper(Context context, String name) {
        super(context, name);
    }

    @Override
    public void onCreate(Database db) {
        super.onCreate(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        super.onUpgrade(db, oldVersion, newVersion);
        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {
            @Override
            public void onCreateAllTables(Database db, boolean ifNotExists) {
                DaoMaster.createAllTables(db, ifNotExists);
            }

            @Override
            public void onDropAllTables(Database db, boolean ifExists) {
                DaoMaster.dropAllTables(db, ifExists);
            }
        }, OrderBeanDao.class);
    }
}
